/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!		\file		prpex_bool.h
  \date		june 2011
  \author		TNick

  \brief		bool class


 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Please read ReadMe.txt and Licence.txt in root folder
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __PRPEX_BOOL_INC__
#define __PRPEX_BOOL_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

#include	<QString>
#include	"prpmdl.h"
#include	"prptpl.h"

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */


/// class representing a bool
/**
*	bools are diffrent from all other types; they are hosting subitems
*	and are the only type allowed at top level
*/
class PEX_bool : public PrpTpl		{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */

	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

	/// this is the value of this item
	bool		b_value;

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	/// constructor;
	PEX_bool		(
			PrpMdl*		pa_mdl,		/**< father model */
			PrpNode*	pa_fth,		/**< father item; NULL for top level */
			QString		stra_name,	/**< name of entry */
			QString		stra_descr,	/**< description of entry */
			bool		ba_val		/**< initial value */
			) : PrpTpl(pa_mdl, pa_fth, PrpTpl::BOOLEAN, stra_name, stra_descr)
		{ b_value = ba_val;  iconDec(true);	 }

	/// destructor;
	virtual				~PEX_bool		(void) {}


	/// request actual value in text form
	virtual QVariant		valAsText	(void)
		{	return (b_value ? QObject::tr("True") : QObject::tr("False")); }
	/// request decoration for the value
	virtual	QVariant		valAsDecor	(void)
		{

		return QIcon(":/icons/check.png");
/*
		return (b_value ?
					QIcon(":/icons/check.png") :
					QIcon(":/icons/uncheck.png"));*/}
	/// request to change the value made by user
	virtual bool			changeVal	(QVariant new_value);
	/// create editor for this type of item
	virtual	QWidget*	editCreate	(
			QWidget *					parent,
			const QStyleOptionViewItem	&option
			);
	/// load data from item to editor
	virtual	void		editLoad	(
			QWidget *					editor
			);
	/// save data from editor to item
	virtual	void		editSave	(
			QWidget *					editor
			);
	//	/// update geometry for the editor
	//	virtual	void		editResize	(
	//		QWidget *					editor,
	//		const QStyleOptionViewItem	&option
	//		);
	/// informed about a click on associated icon
	virtual void		editIcon	(PrpView * prp_v, QModelIndex the_idx);


	inline bool			value		(void)
		{ return b_value; }
	/// sets the name of this entry
	inline void			setValue	(bool b_new_value)
		{ b_value = b_new_value; }


	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class PEX_bool	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __PRPEX_BOOL_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
